www.gusucode.com > VC++ 代码实现绘制生成一个五角星-源码程序 > VC++ 代码实现绘制生成一个五角星-源码程序/code/FiveView.cpp
//Download by http://www.NewXing.com // FiveView.cpp : implementation of the CFiveView class // #include "stdafx.h" #include "Five.h" #include "FiveDoc.h" #include "FiveView.h" #include "Pentacle.h" #include "SetDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CFiveView IMPLEMENT_DYNCREATE(CFiveView, CView) BEGIN_MESSAGE_MAP(CFiveView, CView) //{{AFX_MSG_MAP(CFiveView) ON_COMMAND(ID_SETTING, OnSetting) //}}AFX_MSG_MAP // Standard printing commands ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint) ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint) ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CFiveView construction/destruction CFiveView::CFiveView() { // TODO: add construction code here m_pDraw = new CPentacle; m_pDraw->CalculateFivePoint(100, 100); // m_pDraw->CalculatePoint(100, 100, 12); } CFiveView::~CFiveView() { if ( NULL != m_pDraw ) { delete m_pDraw; m_pDraw = NULL; } } BOOL CFiveView::PreCreateWindow(CREATESTRUCT& cs) { // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs return CView::PreCreateWindow(cs); } ///////////////////////////////////////////////////////////////////////////// // CFiveView drawing void CFiveView::OnDraw(CDC* pDC) { CFiveDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // TODO: add draw code for native data here m_pDraw->Draw(pDC); // 绘制 } ///////////////////////////////////////////////////////////////////////////// // CFiveView printing BOOL CFiveView::OnPreparePrinting(CPrintInfo* pInfo) { // default preparation return DoPreparePrinting(pInfo); } void CFiveView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) { // TODO: add extra initialization before printing } void CFiveView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) { // TODO: add cleanup after printing } ///////////////////////////////////////////////////////////////////////////// // CFiveView diagnostics #ifdef _DEBUG void CFiveView::AssertValid() const { CView::AssertValid(); } void CFiveView::Dump(CDumpContext& dc) const { CView::Dump(dc); } CFiveDoc* CFiveView::GetDocument() // non-debug version is inline { ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CFiveDoc))); return (CFiveDoc*)m_pDocument; } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CFiveView message handlers void CFiveView::OnSetting() { // TODO: Add your command handler code here CSetDlg dlg(m_pDraw); dlg.DoModal(); }